#include "title.h"

model::title::title(const model::dom &node)
{
	parse(node);
}

void model::title::parse(const model::dom &node)
{
	_title = node.find_attrib("name");
	_filename = node.find_attrib("file");
	stringstream ss;
	ss.str(node.find_attrib("duration"));
	ss >> _duration;
}

void model::title::print() const
{
	cout << "Title: " << _title << " Filename: " << _filename 
		<< " Duration: " << _duration << endl;
}

string model::title::to_xml() const
{
	boost::shared_ptr<model::dom> n(new model::dom("title"));
	n->insert_attrib("name", _title);
	n->insert_attrib("file", _filename);

	stringstream strm;
	strm << _duration;

	string tmp = "<title name=\"" + _title + "\" file=\"" + _filename + 
			"\" duration=\"" + strm.str() + "\" />";

	return tmp;
}

